import DisciplinaTopico.TopicoDAOException;
import DisciplinaTopico.TopicoDAOXML;
import DisciplinaTopicoView.DisciplinaView;
import Media.MediaController;
import ProvaView.TelaParametrosProva;
import QuestaoView.QuestaoView;
import java.awt.Dimension;

public class TelaPrincipal extends javax.swing.JFrame {

    /** Creates new form TelaPrincipal */
    public TelaPrincipal()
    {
        initComponents();
        
        Dimension dim = new Dimension(10, 10);
        this.jLabel1.setMaximumSize(dim);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        btnDisciplina = new javax.swing.JButton();
        btnQuestao = new javax.swing.JButton();
        btnProva = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("JABAR - Trabalho 2");
        setResizable(false);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Bem vindo!\nConstrua um modelo de prova completo de maneira rápida e simples.\n"); // NOI18N
        jLabel1.setMaximumSize(new java.awt.Dimension(100, 100));
        jLabel1.setMinimumSize(new java.awt.Dimension(100, 100));
        jLabel1.setPreferredSize(new java.awt.Dimension(100, 100));
        jLabel1.setVerifyInputWhenFocusTarget(false);

        btnDisciplina.setText("Disciplina");
        btnDisciplina.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnDisciplinaMouseClicked(evt);
            }
        });

        btnQuestao.setText("Questão");
        btnQuestao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuestaoActionPerformed(evt);
            }
        });

        btnProva.setText("Prova");
        btnProva.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnProvaMouseClicked(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Myriad Web Pro Condensed", 1, 36)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(89, 35, 198));
        jLabel2.setText("JABAR");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel3.setText("projeto");

        jLabel4.setText("O programa JABAR oferece apoio ao desenvolvimento de provas de qualquer disciplina. ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(68, 68, 68)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel4)
                    .addComponent(btnDisciplina, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)
                    .addComponent(btnQuestao, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)
                    .addComponent(btnProva, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2))
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 455, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(84, 84, 84))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addGap(37, 37, 37)
                .addComponent(btnDisciplina)
                .addGap(18, 18, 18)
                .addComponent(btnQuestao)
                .addGap(18, 18, 18)
                .addComponent(btnProva)
                .addGap(52, 52, 52))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnDisciplinaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnDisciplinaMouseClicked

        try
        {
            DisciplinaView discView = new DisciplinaView(new TopicoDAOXML());
            discView.setVisible(true);
        }
        catch (TopicoDAOException ex)
        {
            MediaController.showErrorMessage("ERRO: Não foi possivel abrir o modulo de disciplina. \nDetalhes:" + ex.getMessage(),"Erro ao abrir modulo");
        }

    }//GEN-LAST:event_btnDisciplinaMouseClicked

    private void btnQuestaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuestaoActionPerformed

        try
        {
            QuestaoView viewQuestao = new QuestaoView(new TopicoDAOXML());
            viewQuestao.setVisible(true);
        }
        catch (TopicoDAOException topicoEx)
        {
            MediaController.showErrorMessage("Não foi possivel realizar a conexão com o banco de dados. Exceção: " + topicoEx.getMessage(),"Erro na conexão");
        }        
    }//GEN-LAST:event_btnQuestaoActionPerformed

    private void btnProvaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnProvaMouseClicked

        try
        {
            TelaParametrosProva telaParametrosProva = new TelaParametrosProva(new TopicoDAOXML());
            telaParametrosProva.setVisible(true);
        }
        catch (TopicoDAOException topicoEx)
        {
            MediaController.showErrorMessage("Não foi possivel realizar a conexão com o banco de dados. Exceção: " + topicoEx.getMessage(),"Erro na conexão");
        }
    }//GEN-LAST:event_btnProvaMouseClicked

    /**
    * @param args the command line arguments
    */
    public static void main(String args[])
    {
        java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                new TelaPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDisciplina;
    private javax.swing.JButton btnProva;
    private javax.swing.JButton btnQuestao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    // End of variables declaration//GEN-END:variables

}
